﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IDao.cs" company="CodePlex">
//   Copyright © CodePlex 2012
// </copyright>
// <summary>
//   Defines the IDao type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace DataFramework.Interfaces
{
    using System.Collections.Generic;
    using System.Data;

    using DataFramework.QueryConditions;

    /// <summary>
    /// Interface that all Data Access Objects should subscribe to. This interface provides all the CRUD functionality.
    /// </summary>
    /// <typeparam name="T">T must be a class with a parameterless constructor.</typeparam>
    public interface IDao<T> where T : class, new()
    {
        /// <summary>
        /// Loads all.
        /// </summary>
        /// <returns>An enumerable list of items of type T.</returns>
        IEnumerable<T> LoadAll();

        /// <summary>
        /// Loads all.
        /// </summary>
        /// <param name="conditions">The conditions.</param>
        /// <returns>An enumerable list of items of type T.</returns>
        IEnumerable<T> LoadAll(IEnumerable<BaseQueryCondition> conditions);

        /// <summary>
        /// Loads all as table.
        /// </summary>
        /// <returns>A data table containing the db data.</returns>
        DataTable LoadAllAsTable();

        /// <summary>
        /// Loads all as table.
        /// </summary>
        /// <param name="conditions">The conditions.</param>
        /// <returns>A data table containing the db data.</returns>
        DataTable LoadAllAsTable(IEnumerable<BaseQueryCondition> conditions);

        /// <summary>
        /// Adds the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        void Add(T item);

        /// <summary>
        /// Removes the specified card.
        /// </summary>
        /// <param name="card">The card.</param>
        void Remove(T card);

        /// <summary>
        /// Updates the specified card.
        /// </summary>
        /// <param name="card">The card.</param>
        void Update(T card);
    }
}
